﻿using JustMetClient.Commons;
using JustMetClient.Models.InfoModels;
using JustMetClient.Models.WebApiModels;
using JustMetClient.Modules.LoginModule;
using JustMetClient.Modules.WebConfigModule;
using JustMetClient.Modules.WebModule;
using Azylee.Core.DataUtils.CollectionUtils;
using Azylee.Core.DataUtils.UnitConvertUtils;
using Azylee.Core.IOUtils.DirUtils;
using Azylee.Core.NetUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JustMetClient.Modules.PlanTaskModule
{
    public class PlanTaskM180
    {

        /// <summary>
        /// 180分钟任务（3小时任务）
        /// </summary>
        public static void Do()
        {
            //读取服务器远程配置信息
            WebConfigHelper.Read();

            //定期自动登录网络认证
            if (R.Flag.AutoLogin && LoginHelper.AutoLogin()) R.Toast.AutoShow("提示", "网络认证成功：" + R.Account);

            #region 客户端文件占用超过100MB警告
            R.AppSize = DirTool.GetPathSize(R.Paths.Root);//获取程序占用空间
            if (R.AppSize > 100 * 1024 * 1024)
            {
                WebApiSendQueue.Add(R.Web.Send.ClientCollection, new ClientUserDefinedInfoModel()
                {
                    Type = "客户端文件占用超过100MB",
                    Values = ArrayTool.Formatter(new string[] { R.AppSize.ToString(), $"{ByteConvertTool.Cvt(R.AppSize, "MB")} MB" }, "", 10),
                }, HttpMethodType.Post);
            }
            #endregion
        }
    }
}
